#!/usr/bin/env Rscript
## This file runs BRS on the probabilistic simulated data for J=10

set.seed(123)  # shouldn't matter, since we pass a seed to the BRS function, but just in case

i <- 4
ruleSet_BRS_pois_dgp4 <- list() # list of all list (one for each sample size) of rule sets of this dgp
for(j in 1:length(sampleSize)){ # Loop through all sample sizes
  # for each rep
  ruleSet_BRS_pois_dgp4[[j]] <- foreach (k=1:numSims) %dopar% {
    cat("i=", i, "j=", j, "; k=", k, " \n", sep="")
    
    data <- allData[[i]][[k]]
    X <- data[allIndices[[j]][[k]],-ncol(data)]
    Y <- data[allIndices[[j]][[k]], ncol(data)] # Last column is Y
    
    lambda <- 1
    nu <- getEta(sampleSize[j])  # note: BRS_0.0.0.9006 uses nu to refer to eta from the paper
    
    str <- ncol(X)
    alpha_1 <- a1/str; alpha_2 <- a2/str; beta_1 <- b1/str; beta_2 <- b2/str
    
    BRS(df=X, Y=Y,
        maxLen=maxLen, trainProp=train_prop,
        numIter=Niteration, numChain=Nchain,
        supp=supp, numMine=numMine,
        alpha_1=alpha_1, alpha_2=alpha_2,
        beta_1=beta_1, beta_2=beta_2,
        prior_type="poisson",
        alpha_l=NULL, beta_l=NULL,  # not used for the poisson version
        lambda=lambda, nu=nu,  # note: BRS_0.0.0.9006 uses nu to refer to eta from the paper
        bootstrap=F,
        print=F,
        seed=seeds[[i]][[j]][k])[[1]][[1]]
  }
}

save(ruleSet_BRS_pois_dgp4, file="sim/out/sim_out4.rda")